package com.firewolf.spring;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.spring.entities.Car;
import com.spring.entities.DataSource;
import com.spring.entities.RichPerson;
import com.spring.entities.User;
import com.spring.entities.User2;

/**
 * 
 * @author lx
 *
 */
public class MainDriver {
	
	private ApplicationContext ctx = null;
	
	/**
	 * 初始化
	 */
	@Before
	public void init(){
		ctx = new ClassPathXmlApplicationContext("spring.xml");
	}
	
	@Test
	public void simpleValue(){
		Car car = (Car) ctx.getBean("car1");
		System.out.println(car);
	}
	
	@Test
	public void specialValue(){
		Car car = (Car) ctx.getBean("car2");
		System.out.println(car);
	}
	
	@Test
	public void ref(){
		User u = (User) ctx.getBean("user1");
		System.out.println(u);
	}
	@Test
	public void collection(){
		RichPerson richPerson = (RichPerson) ctx.getBean("richPerson");
		System.out.println(richPerson);
	}
	@Test
	public void collection1(){
		DataSource datasource = (DataSource) ctx.getBean("datasource");
		System.out.println(datasource);
	}
	@Test
	public void collection2(){
		RichPerson richPerson = (RichPerson) ctx.getBean("richPerson2");
		System.out.println(richPerson);
	}
	
	@Test
	public void nullVal(){
		User2 user = (User2) ctx.getBean("user22");
		System.out.println(user);
	}
	
	
	
}                                                                                     
